package com.xmg.day08;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author: mazhongqing
 * @Date: 2020/11/3 10:17
 */
@Slf4j(topic = "m.topic")
public class ThreadStateDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            log.debug("running..");
        });

        Thread t2 = new Thread(()->{
            while(true){

            }
        });
        t2.start();

        Thread t3 = new Thread(()-> log.debug("running.."));
        t3.start();

        Thread t4 = new Thread(()->{
            synchronized (ThreadStateDemo.class){
                try {
                    Thread.sleep(100000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t4.start();

        Thread t5 = new Thread(()->{
            try {
                t2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t5.start();

        Thread t6 = new Thread(()->{
            synchronized (ThreadStateDemo.class){
                try {
                    Thread.sleep(100000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t6.start();

        Thread.sleep(1000);

        System.out.println("t1 state:"+t1.getState());
        System.out.println("t2 state:"+t2.getState());
        System.out.println("t3 state:"+t3.getState());
        System.out.println("t4 state:"+t4.getState());
        System.out.println("t5 state:"+t5.getState());
        System.out.println("t6 state:"+t6.getState());

    }
}
